import SwiftUI
import SPGlassKit

public struct GlassThinkingIndicatorExample: GlassExample {
    public static let componentID = "glass-thinking-indicator"

    /// Fictitious activity labels, written by the host — never text coming from a model.
    private let stages: [(kind: GlassActivityKind, label: String)] = [
        (.thinking, "Preparing the sample answer"),
        (.searching, "Searching the sample library"),
        (.reading, "Reading 3 sample documents"),
        (.writing, "Writing the summary"),
        (.waiting, "Waiting for your confirmation"),
    ]
    @State private var stage = 0

    public init() {}

    public var body: some View {
        VStack(alignment: .leading, spacing: 16) {
            Text("Sample data · simulated activity")
                .font(.caption)
                .foregroundStyle(.secondary)

            GlassThinkingIndicator(stages[stage].kind, label: stages[stage].label)
            GlassButton("Next activity", systemImage: "forward.end") {
                stage = (stage + 1) % stages.count
            }

            Divider()
            ForEach(stages.indices, id: \.self) { index in
                GlassThinkingIndicator(stages[index].kind, label: stages[index].label, announcesChanges: false)
            }
            GlassThinkingIndicator(.custom(systemImage: "arrow.down.circle"), label: "Downloading the sample model, which has a long label that wraps on narrow screens", announcesChanges: false)
            GlassThinkingIndicator(announcesChanges: false)
            GlassThinkingIndicator(.waiting, label: "Plain style, for a status line", announcesChanges: false, style: .plain)

            Divider()
            Text("Reduce Motion (simulated): static symbol")
                .font(.caption)
            GlassThinkingIndicator(.searching, label: "Searching the sample library", announcesChanges: false)
                .glassSimulatedAccessibility(reduceMotion: true)
        }
        .padding()
    }
}

#Preview("GlassThinkingIndicator") { GlassThinkingIndicatorExample().glassTheme(.crystal) }
